import React, { Component } from 'react'

export default class scud extends Component {
    constructor(props){
        super(props)
        this.state={
            text:"测试"
        }
    }
    fun=()=>{
       this.setState({
           text:"我变了"
       }) 
    }
    shouldComponentUpdate(nextProps,nextState){
        // console.log(nextProps)  //{}
        // console.log(nextState)   //{text: "我变了"}
        // return false

        console.log(nextProps)  //{}
        console.log(nextState)   //{text: "我变了"}
        return true

    }
    render() {
        return (
            <div>
                <h1>我是学习判断组件是否更新的生命周期钩子</h1>
                <p>{this.state.text}</p>
                <button onClick={this.fun}>点我测试生命周期钩子</button>
            </div>
        )
    }
}
